<?php
class helloMvcConfiguration implements ezcMvcDispatcherConfiguration
{
	function createRequestParser()
	{
		$parser = new ezcMvcHttpRequestParser;
		$parser->prefix = preg_replace( '@/index\.php$@', '', $_SERVER['SCRIPT_NAME'] );
		return $parser;
	}

	function createRouter( ezcMvcRequest $request )
	{
		return new helloRouter( $request );
	}

	function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
	{
		switch ( $routeInfo->matchedRoute )
		{
			case '/convertDb':
				return new ConvertView( $request, $result );
			
			case '/list':
			case '/export':
				return new NddListView( $request, $result );
			
			case '/search':
			case '/search/:word':
				return new NddListView( $request, $result );
			
			case '/create':
				return new NddManageView( $request, $result );
				
			case '/edit/:nddId':
				return new NddEditView( $request, $result );
			
			case '/save':
			case '/save/:nddId':
			case '/delete/:nddId':
				return new NddAjaxManageView( $request, $result );
				
			case '/confirm-delete/:nddId':
				return new NddSaveView( $request, $result );
			
			default:
				return new  NddListView( $request, $result );
		}
	}

	function createResponseWriter( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result, ezcMvcResponse $response )
	{
		return new ezcMvcHttpResponseWriter( $response );
	}

	function createFatalRedirectRequest( ezcMvcRequest $request, ezcMvcResult $result, Exception $response )
	{
		echo $response->getMessage();

		$req = clone $request;
		$req->uri = '/FATAL';

		return $req;
	}

	function runResultFilters( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
	{
		$result->variables['installRoot'] = preg_replace( '@/index\.php$@', '', $_SERVER['SCRIPT_NAME'] );
	}

	function runPreRoutingFilters( ezcMvcRequest $request )
	{
	}

	function runRequestFilters( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request )
	{
	}

	function runResponseFilters( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result, ezcMvcResponse $response )
	{
	}

}

?>